package encdb

import (
	"fhe-search-cloud/models"
	"fmt"

	"github.com/jmoiron/sqlx"
)

func AddOneTerm(tx *sqlx.Tx, term *models.TermItem, termLen int) (termId int) {
	sql := fmt.Sprintf("INSERT INTO term%d (bucket8, fhe_term) VALUES (:bucket8, :fhe_term)", termLen)
	tx.NamedExec(sql, term)
	tx.Get(&termId, "SELECT LAST_INSERT_ID();")
	return termId
}
